package org.example.events.hostable.sales;

import org.example.item.wallet.WalletActions;
import org.example.models.abstracts.AbstractItem;
import org.example.models.interfaces.Action;
import org.example.person.Person;

public class BuyAction implements Action<Person> {

    private final Person seller;
    private int amount;
    private AbstractItem item;


    public BuyAction(Person seller) {
        this.seller = seller;
    }

    public BuyAction amount(int amount) {
        this.amount = amount;
        return this;
    }

    public BuyAction item(AbstractItem item) {
        this.item = item;
        return this;
    }

    @Override
    public void perform(Person buyer) {
        seller.removeOwnable(item);
        buyer.addOwnable(item);
        buyer.act(WalletActions.transferMoney(seller, amount));
    }
}
